import React, { useEffect, useState } from 'react'
import api from '../../../../api'
import HomeHotView from '../HomeHotView'

export default function HomeHot ({ city }) {

  const [data1, setData1] = useState([])
  const [data2, setData2] = useState([])

  useEffect(() => {
    api.hot1({ city }).then((res) => {
      if (res.data.status === 200) {
        // console.log(res.data.result);
        setData1(res.data.result)
      }
    }).catch((error) => {
      console.log(error);
    })
  }, [])


  useEffect(() => {
    api.hot2().then((res) => {
      if (res.data.status === 200) {
        // console.log(res.data.result);
        setData2(res.data.result)
      }
    }).catch((error) => {
      console.log(error);
    })
  }, [])


  return (
    <div>
      <HomeHotView data={data1} title="热销单品" />
      <HomeHotView data={data2} title="家庭常用" />
    </div>
  )
}
